package com.wq.hadoop.workspace.map;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @Author: wangqiang20995
 * @Date:2018/11/1
 * @Description:
 * @Resource:
 */
public class SimpleMap extends Mapper<LongWritable,Text,Text,Text> {

    public void map(LongWritable key,Text value,Context context) throws IOException,InterruptedException{
        String line = value.toString();

        try{
            String[] lineSplit = line.split("\\|");
            String id = lineSplit[0];
            String price = lineSplit[2];
            String date = lineSplit[4];

            context.write(new Text(id),new Text(date + "_" + price));
        }catch (ArrayIndexOutOfBoundsException e){
            e.printStackTrace();
        }
    }
}
